home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1997 January: Mac OS SDK / Dev.CD Jan 97 SDK2.toast / Development Kits (Disc 2) / OpenDoc Development Framework / ODFDev / ODF / OS / FWGraphx / FWShape.cpp < prev    next >
Encoding:
Text File  |  1996-09-17  |  5.9 KB  |  213 lines  |  [TEXT/MPS ]

  1. //========================================================================================
  2. //
  3. //    File:                FWShape.cpp
  4. //    Release Version:    $ ODF 2 $
  5. //
  6. //    Copyright:    (c) 1993 - 1996 by Apple Computer, Inc., all rights reserved.
  7. //
  8. //========================================================================================
  9.  
  10. #include "FWOS.hpp"
  11.  
  12. #ifndef FWSHAPE_H
  13. #include "FWShape.h"
  14. #endif
  15.  
  16. #ifndef FWFXMATH_H
  17. #include "FWFxMath.h"
  18. #endif
  19.  
  20. // ----- Foundation Includes -----
  21.  
  22. #ifndef FWSTREAM_H
  23. #include "FWStream.h"
  24. #endif
  25.  
  26. //========================================================================================
  27. //    RunTime Info
  28. //========================================================================================
  29.  
  30. #ifdef FW_BUILD_MAC
  31. #pragma segment FWGraphics_Shape
  32. #endif
  33.  
  34. FW_DEFINE_AUTO(FW_CShape)
  35. FW_DEFINE_CLASS_M0(FW_CShape)
  36.  
  37. //========================================================================================
  38. //    class FW_CShape
  39. //========================================================================================
  40.  
  41. //----------------------------------------------------------------------------------------
  42. //    FW_CShape::FW_CShape
  43. //----------------------------------------------------------------------------------------
  44.  
  45. FW_CShape::FW_CShape(FW_ERenderVerbs renderVerb,
  46.                      const FW_CInk& ink,
  47.                      const FW_CStyle& style,
  48.                      const FW_CFont& font) :
  49.     fRenderVerb(renderVerb),
  50.     fInk(ink),
  51.     fStyle(style),
  52.     fFont(font)
  53. {    
  54.     FW_END_CONSTRUCTOR
  55. }
  56.  
  57. //----------------------------------------------------------------------------------------
  58. //    FW_CShape::FW_CShape
  59. //----------------------------------------------------------------------------------------
  60.  
  61. FW_CShape::FW_CShape(const FW_CShape& other):
  62.     fInk(other.fInk),
  63.     fStyle(other.fStyle),
  64.     fFont(other.fFont),
  65.     fRenderVerb(other.GetRenderVerb())
  66. {
  67.     FW_END_CONSTRUCTOR
  68. }
  69.  
  70. //----------------------------------------------------------------------------------------
  71. //    FW_CShape::FW_CShape
  72. //----------------------------------------------------------------------------------------
  73.  
  74. FW_CShape::FW_CShape(FW_CReadableStream& stream)
  75. {
  76.     stream >> fInk;
  77.     stream >> fStyle;
  78.     stream >> fFont;
  79.     stream.Read((char*)&fRenderVerb, sizeof(fRenderVerb));
  80.  
  81.     FW_END_CONSTRUCTOR
  82. }
  83.  
  84. //----------------------------------------------------------------------------------------
  85. //    FW_CShape::~FW_CShape
  86. //----------------------------------------------------------------------------------------
  87.  
  88. FW_CShape::~FW_CShape()
  89. {
  90.     FW_START_DESTRUCTOR
  91. }
  92.  
  93. //----------------------------------------------------------------------------------------
  94. //    FW_CShape::operator=
  95. //----------------------------------------------------------------------------------------
  96.  
  97. FW_CShape& FW_CShape::operator=(const FW_CShape& other)
  98. {
  99.     if (this != &other)
  100.     {
  101.         fInk = other.fInk;
  102.         fStyle = other.fStyle;
  103.         fFont = other.fFont;
  104.         fRenderVerb = other.fRenderVerb;
  105.     }
  106.     
  107.     return *this;
  108. }
  109.  
  110. //----------------------------------------------------------------------------------------
  111. //    FW_CShape::Purge
  112. //----------------------------------------------------------------------------------------
  113.  
  114. void FW_CShape::Purge()
  115. {
  116. }
  117.  
  118. //----------------------------------------------------------------------------------------
  119. //    FW_CShape::Flatten
  120. //----------------------------------------------------------------------------------------
  121.  
  122. void FW_CShape::Flatten(FW_CWritableStream& stream) const
  123. {
  124.     stream << fInk;
  125.     stream << fStyle;
  126.     stream << fFont;
  127.     stream.Write((char*)&fRenderVerb, sizeof(fRenderVerb));
  128. }
  129.  
  130. //----------------------------------------------------------------------------------------
  131. //    FW_CShape::GetUnSharedInk
  132. //----------------------------------------------------------------------------------------
  133.  
  134. FW_CInk& FW_CShape::GetUnSharedInk()
  135. {
  136.     if (fInk.GetRefCount() > 1)
  137.         fInk = fInk.Copy();
  138.         
  139.     return fInk;
  140. }
  141.  
  142. //----------------------------------------------------------------------------------------
  143. //    FW_CShape::GetUnSharedStyle
  144. //----------------------------------------------------------------------------------------
  145.  
  146. FW_CStyle& FW_CShape::GetUnSharedStyle()
  147. {
  148.     if (fStyle.GetRefCount() > 1)
  149.         fStyle = fStyle.Copy();
  150.         
  151.     return fStyle;
  152. }
  153.  
  154. //----------------------------------------------------------------------------------------
  155. //    FW_CShape::GetUnSharedFont
  156. //----------------------------------------------------------------------------------------
  157.  
  158. FW_CFont& FW_CShape::GetUnSharedFont()
  159. {
  160.     if (fFont.GetRefCount() > 1)
  161.         fFont = fFont.Copy();
  162.         
  163.     return fFont;
  164. }
  165.  
  166. //----------------------------------------------------------------------------------------
  167. //    FW_CShape::Write
  168. //----------------------------------------------------------------------------------------
  169.  
  170. void FW_CShape::Write(FW_CWritableStream& stream, FW_ClassTypeConstant type, const void *object)
  171. {
  172. FW_UNUSED(type);
  173.     ((FW_CShape*)object)->Flatten(stream);
  174. }
  175.  
  176. //----------------------------------------------------------------------------------------
  177. //    FW_CShape::SetRenderVerb
  178. //----------------------------------------------------------------------------------------
  179.  
  180. void FW_CShape::SetRenderVerb(FW_ERenderVerbs renderVerb)
  181. {
  182.     fRenderVerb = renderVerb;
  183. }
  184.  
  185. //----------------------------------------------------------------------------------------
  186. //    FW_CShape::SetInk
  187. //----------------------------------------------------------------------------------------
  188.  
  189. void FW_CShape::SetInk(const FW_CInk& newInk)
  190. {
  191.     fInk = newInk;
  192. }
  193.  
  194. //----------------------------------------------------------------------------------------
  195. //    FW_CShape::SetStyle
  196. //----------------------------------------------------------------------------------------
  197.  
  198. void FW_CShape::SetStyle(const FW_CStyle& newStyle)
  199. {
  200.     fStyle = newStyle;
  201. }
  202.                         
  203. //----------------------------------------------------------------------------------------
  204. //    FW_CShape::SetFont
  205. //----------------------------------------------------------------------------------------
  206.  
  207. void FW_CShape::SetFont(const FW_CFont& newFont)
  208. {
  209.     fFont = newFont;
  210. }
  211.                 
  212.                         
  213.